import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/view/login'),
    hidden: true
  },
  {
    path: '/',
    component: () => import('@/view/index'),
    meta: { title: '首页', icon: 'el-icon-s-home' },
    children: [
      {
        path: '/sysUser',
        redirect: '/sysUser/index',
        component: () => import('@/components/Layout'),
        meta: { title: '用户管理', icon: 'el-icon-data-board', roles: ['SYS_USER_DEFAULT'] },
        children: [
          {
            path: '/sysUser/index',
            component: () => import('@/view/sysUser/index'),
            meta: { icon: 'el-icon-document', title: '用户列表', roles: ['SYS_USER_DEFAULT'] }
          },
          {
            path: '/sysUser/view',
            component: () => import('@/view/sysUser/view'),
            meta: { icon: 'el-icon-document', title: '用户查看', roles: ['SYS_USER_VIEW'] }
          },
          {
            path: '/sysUser/edit',
            component: () => import('@/view/sysUser/edit'),
            meta: { icon: 'el-icon-document', title: '用户编辑', roles: ['SYS_USER_EDIT'] }
          }
        ]
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/view/404'),
    hidden: true
  },
  { path: '*', redirect: '/404', hidden: true }
]

export const asyncRoutes = [
 
]


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router